package com.hiwan.framework.servlet.tags;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.Tag;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.commons.lang.StringUtils;

import com.hiwan.system.pojo.UserInfo;
import com.hiwan.system.util.UserCacheUtils;

/**
 * 
 
 * Datetime   ： 2016年1月14日 下午5:49:39<br>
 * Title      :  UserNameByIdTag.java<br>
 * Description:  根据用户id获取name <br>
 * Company    :  hiwan<br>
 * @author cbj
 *
 */
public class UserNameByIdTag extends TagSupport {
	private static final long serialVersionUID = 4364554937821296946L;
	private String userId;// 用户Id
	private JspWriter out;

	@Override
	public int doStartTag() {

		try {
			if (StringUtils.isEmpty(userId)) {
				out.print("");
			} else {
				
				UserInfo userInfo = UserCacheUtils.get(userId);
				out = this.pageContext.getOut();
				
				out.print(userInfo.getUserName());
			}
		} catch (Exception e) {
		}
		return Tag.EVAL_PAGE;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public JspWriter getOut() {
		return out;
	}

	public void setOut(JspWriter out) {
		this.out = out;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

}
